package cn.gcjxsc.messaging.sink;

import cn.gcjxsc.common.consts.RedPackType;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.messaging.Message;
import org.springframework.util.StringUtils;

/**
 * @author pumbaa
 * @since 1.0
 */
@EnableBinding(OrderShareSink.class)
public class MemberShareCashSink extends CashSink{

    @StreamListener(OrderShareSink.SHARE_NAME)
    public void process(Message<String> message){
        String sn = message.getPayload();
        logger.info("接收分享红包通知:{}", sn);
        if (StringUtils.isEmpty(sn)) {
            logger.error("订单号为空");
            return;
        }
        processCash(sn, RedPackType.SHARE.getType(), "分享店铺消费,回馈红包");
    }
}
